package cn.jinshengda.controller;


import cn.jinshengda.Dto.ResumeDto;
import cn.jinshengda.entity.Resume;
import cn.jinshengda.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-01-08
 */
@RestController
@CrossOrigin
public class ResumeController {
   @Autowired
   private ResumeService resumeService;
    /*
    添加员工履历
     */
   @PostMapping("emp/addResume/{employeeId}")
   public void addResume(@RequestBody ResumeDto resumeDto,@PathVariable("employeeId") Integer employeeId){
       Date[] workDuring = resumeDto.getWorkDuring();
//       for (int i = 0; i < workDuring.length; i++) {
//           System.out.println(workDuring[i]+"---------------------------");
//       }
       Resume resume = new Resume();
       resume.setEmployeeId(employeeId);
       resume.setJobName(resumeDto.getJobName());
       resume.setStartDate(workDuring[0]);
       resume.setEndDate(workDuring[1]);

       resumeService.save(resume);
   }

   @GetMapping
   public Resume queryById(Integer id){
       Resume resume = resumeService.getById(id);
       return resume;
   }
}

